package com.limeng.datastruts.queue;

public class ArrayQueue {

    public static void main(String[] args) {
        ArrayQueue queue = new ArrayQueue(8);
        queue.push(4);
        queue.push(5);
        queue.push(1);
        queue.push(6);

        System.out.println(queue.pop());
        System.out.println(queue.pop());
        System.out.println(queue.pop());
        System.out.println(queue.pop());
    }

    private int[] nums;
    private int head;
    private int tail;

    public ArrayQueue(int size) {
        nums = new int[size];
    }

    public boolean push(int num){
        if(tail>=nums.length) return false;
        nums[tail] = num;
        tail++;
        return true;
    }

    public int pop(){
        if(head == tail) return 0;
        int num = nums[head];
        head++;
        return num;
    }

}
